<extend name="base" />

<block name="panel">

<div>
  <input type="hidden" value="{$parent['id']}" id="parent_id" />
  <input type="hidden" value="{$parent['name']}" id="parent_name" />
</div>

  <div class="board">
    <div>
      <button class="btn btn-info" id="update"> save </button>
    </div>

    <input type="hidden" value="{$news['news_id']}" id="news_id">
    <br/>
    <table class="table table-bordered">
      <colgroup>
        <col width="10%"></col><col width="90%"></col>
      </colgroup>
      <tr>
        <td>English</td>
        <td><textarea id="news_en" value="" style="width:100%;" rows="12">{$news['news_en']}</textarea></td>
      </tr>
      <tr>
        <td>Traditional Chinese</td>
        <td><textarea id="news_tc" value="" style="width:100%;" rows="12">{$news['news_tc']}</textarea></td>
      </tr>
      <tr>
        <td>Simplified Chinese</td>
        <td><textarea id="news_sc" value="" style="width:100%;" rows="12">{$news['news_sc']}</textarea></td>
      </tr>
    </table>


  </div>

  <script type="text/javascript">
  	$(document).ready(function(){

      $("#update").click(function(){
  			var news_en = $("#news_en").val();
  			var news_sc = $("#news_sc").val();
  			var news_tc = $("#news_tc").val();
        var news_id = $("#news_id").val();
  			
        $.ajax({
  				type: "POST",
  				url: baseurl+"News/edit",
  				dataType: "json",
  				data:{
            news_id: news_id,
  					news_en: news_en,
  					news_sc: news_sc,
  					news_tc: news_tc,
  				},
  				success: function(data){
  					if(data){
              alert("OK");
            }else{
              alert("Failed");
            }
  				},
  			});  // ajax finished


  		});		
  	});
    
  </script>

</block>